<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>标题</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<table class="layui-hide" id="dataList" lay-filter="dataList"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="deal">审核</a>
</script>

<script type="text/javascript" src="/lib/layui/layui.js"></script>
<script src="/static/js/main.js"></script>
<script>
    layui.use(['jquery', 'configureCom', 'configure', 'table', 'sessionFun'], function () {
        var $ = layui.jquery;
        var configure = layui.configure;
        var matchDict = layui.matchDict;
        var table = layui.table;
        var sessionFun = layui.sessionFun;
        var configureCom = layui.configureCom;

        var cols = [[
            {
                field: 'orgName', title: '单位名称'
            },
            {
                field: 'creditCode', title: '统一社会信用代码'
            },
            {
                field: 'submitTime', title: '提交时间'
            },
            {
                field: 'aptitudeType', title: '证书类型', templet: function (d) {
                    return '<p>' + matchDict.name(d.aptitudeType, configure.COMPANY_TYPE_CODE) + '</p>';
                }
            },
            {
                field: 'aptitudeNo', title: '证书编号'
            },
            {title: '操作', toolbar: '#barDemo', width: 220}
        ]];
        configureCom.tableRender(configure.ORG_ZIZHI_WAIT_DEAL_LIST_HTTP, {}, cols, 'dataList', 10, '', 'toolbarOrg');

        //每行操作
        table.on('tool(dataList)', function (obj) {
            var data = obj.data;
            sessionFun.set(configure.SESSION_ZIZHI_LIST_DATA, data);
            if (obj.event === 'deal') {//查看详情
                top.layer.open({
                    type: 2,
                    title: '审核',
                    area: configureCom.Psize1,
                    content: configureCom.nocache(configure.COM_ZIZHI_DETAIL_READ_HTML),
                    btn: ['通过', '不通过'],
                    btnAlign: 'c',
                    yes: function (index, layero) {
                        top.layer.confirm('确认通过吗？', function (childIndex, childLayero) {
                            configureCom.postDataAjax(configure.ORG_ZIZHI_PASS_HTTP, {aptitudeId: data.id}).then(function (res) {
                                top.layer.close(index);
                                top.layer.close(childIndex);
                                top.layer.msg('保存成功！');
                                configureCom.tableReload(true);
                            });
                        });
                    },
                    btn2: function (index, layero) {
                        top.layer.prompt({
                            formType: 2,
                            title: '请填写不通过意见',
                            value: ''
                        }, function (value, childIndex) {
                            if (!value) {
                                top.layer.msg('请填写意见！');
                                return false;
                            }
                            configureCom.postDataAjax(configure.ORG_ZIZHI_NO_PASS_HTTP, {
                                aptitudeId: data.id,
                                auditTxt: value
                            }).then(function (res) {
                                top.layer.close(index);
                                top.layer.close(childIndex);
                                top.layer.msg('保存成功！');
                                configureCom.tableReload(true);
                            });
                            layer.close(index);
                        });
                        return false;
                    }
                });
            }
        });
    });

</script>
</body>
</html>